package com.liang.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;

import com.liang.service.UserService;

public class MyHandlerInterceptor implements HandlerInterceptor{
	@Autowired
	private UserService userService;
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		if(request.getSession().getAttribute("info")!=null) {
			return true;
		}else {
			request.setAttribute("msg", "您还未登录");
			request.getRequestDispatcher("/").forward(request, response);
			return false;
		}
		
	}
}
